Passed
Pull Request — master (#22)
by
unknown
08:10 queued 04:20
created

SelectMissableComponent   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A trackBy 0 3 1
1
import { GameDataService } from './../../data/gameData.service';
2
import { ValueAccessorBase } from './../abstract/ValueAccessorBase';
3
/**
4
   Copyright 2018 June Hanabi
5
6
   Licensed under the Apache License, Version 2.0 (the "License");
7
   you may not use this file except in compliance with the License.
8
   You may obtain a copy of the License at
9
10
       http://www.apache.org/licenses/LICENSE-2.0
11
12
   Unless required by applicable law or agreed to in writing, software
13
   distributed under the License is distributed on an "AS IS" BASIS,
14
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
   See the License for the specific language governing permissions and
16
   limitations under the License.
17
 */
18
19
import { Component, Input } from '@angular/core';
20
21
import {
22
    NG_VALUE_ACCESSOR,
23
} from '@angular/forms';
24
25
declare var window: {
26
    require: any;
27
};
28
29
const _ = window.require("lodash");
30
31
@Component({
32
    selector: 'select-missable',
33
    templateUrl: './select-missable.component.pug',
34
    styleUrls: ['./select-missable.component.scss'],
35
    providers: [
36
        { provide: NG_VALUE_ACCESSOR, useExisting: SelectMissableComponent, multi: true }
37
    ],
38
})
39
export class SelectMissableComponent extends ValueAccessorBase<string> {
40
41
    constructor(
42
        public gd: GameDataService
43
    ) {
44
        super();
45
    }
46
47
    @Input()
48
    public disabled: boolean = false;
49
50
    @Input()
51
    public noneSelectable: boolean = false;
52
53
    get missableList() {
54
        const missableList = this.gd.file("missables").data;
55
        return _.sortBy(missableList, ["name"]);
56
    }
57
58
    trackBy(index: number) {
59
        return index;
60
    }
61
}
62